package test.study.nosql.redis.client.jedis;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class JedisClient {

    private static String HOST = "150.158.110.15";

    private static int PORT = 7379;

    private static Jedis getJedis() {
        JedisPool pool = new JedisPool(new GenericObjectPoolConfig(), HOST, PORT, 60 * 1000);
        return pool.getResource();
    }

    @Test
    public void set_test() {
        getJedis().set("aaaa", "fsdafasdfadsfsd");
    }

    @Test
    public void get_test() {
        getJedis().get("aaa");
    }

    @Test
    public void expire_test() {
        getJedis().expire("aaaa", 10);
    }

    @Test
    public void pub_test() {
        String channel = "test";
        String message = "testtesttesttest";
        getJedis().publish(channel, message);
    }
}
